package org.japo.java.swing.igu;

import java.awt.Color;
import java.awt.Font;
import java.awt.HeadlessException;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import org.japo.java.swing.listener.GER;

public class IGU extends JFrame {
    public IGU() throws HeadlessException {
        iniciarComponentes();
    }
    private void iniciarComponentes() {
        //fuente
        Font f = new Font("Calibri", Font.PLAIN, 20);
        
        //Eventos de accion
        GER gea = new GER(this);
        
        //boton
        JButton btnBoton = new JButton();
        btnBoton.setText("Terminar");
        btnBoton.setFont(f);
        btnBoton.addActionListener(gea);
        btnBoton.setBackground(Color.red);
        
        //panel Principal
        JPanel pnlPrincipal = new JPanel();
        pnlPrincipal.add(btnBoton);
        
        //Ventana
        setContentPane(pnlPrincipal);
        setSize(400, 300);
        setLocationRelativeTo(null);
    }
    
    public void finalizarPrograma() {
        //oculta la ventana
        setVisible(false);
        
        //libera los recursos graficos
        dispose();
        
        //Termina la maquina virtual
        System.exit(0);
    }
}
